<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>计协管理后台</title>

    <!-- Styles -->
    <link href="/css/app.css" rel="stylesheet">

    <!-- Scripts -->
    <script>
        window.Laravel = <?php echo json_encode([
            'csrfToken' => csrf_token(),
        ]); ?>
    </script>
</head>
<body>
<div id="app">
    {{--<passport-clients></passport-clients>--}}
    {{--<passport-authorized-clients></passport-authorized-clients>--}}
    {{--<passport-personal-access-tokens></passport-personal-access-tokens>--}}
    <nav class="navbar navbar-default navbar-static-top">
        <div class="container">
            <div class="navbar-header">

                <!-- Collapsed Hamburger -->
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#app-navbar-collapse">
                    <span class="sr-only">Toggle Navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>

                <!-- Branding Image -->
                <a class="navbar-brand" href="{{ url('admin') }}">
                    计协后台
                </a>
            </div>

            <div class="collapse navbar-collapse" id="app-navbar-collapse">
                @if (!Auth::guest())
                <!-- Left Side Of Navbar -->
                <ul class="nav navbar-nav">
                    @if(\Entrust::can('role_manage') || \Entrust::can('admin_manage') || \Entrust::can('permission_manage'))
                        <li class="dropdown">
                            <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
                                系统功能<span class="caret"></span>
                            </a>
                            <ul class="dropdown-menu" role="menu">
                                @permission(('role_manage'))
                                <li>
                                    <a href="{{ url('/admin/permission/role') }}">角色管理</a>
                                </li>
                                @endpermission
                                @permission(('admin_manage'))
                                <li>
                                    <a href="{{ url('/admin/permission/admin') }}">人员管理</a>
                                </li>
                                @endpermission
                                @permission(('permission_manage'))
                                <li>
                                    <a href="{{ url('/admin/permission/permission') }}">权限管理</a>
                                </li>
                                @endpermission
                            </ul>
                        </li>
                    @endif
                    @if(\Entrust::can('user_manage'))
                        <li class="dropdown">
                            <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
                                用户模块<span class="caret"></span>
                            </a>
                            <ul class="dropdown-menu" role="menu">
                                <li>
                                    <a href="{{ url('/admin/user/exception') }}">异常用户</a>
                                    <a href="{{ url('/admin/user/list') }}">用户列表</a>
                                </li>
                            </ul>
                        </li>
                    @endif
                    @if(Entrust::can('template'))
                        <li class="dropdown">
                            <a href="javascript:;" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
                                运营模块<span class="caret"></span>
                            </a>
                            <ul class="dropdown-menu" role="menu">
                                <li>
                                    <a href="{{ url('/admin/operation/template') }}">模板消息</a>
                                </li>
                            </ul>
                        </li>
                    @endif
                </ul>
                @endif

                <!-- Right Side Of Navbar -->
                <ul class="nav navbar-nav navbar-right">
                    <!-- Authentication Links -->
                    @if (!Auth::guest())
                        <li class="dropdown">
                            <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
                                {{ Auth::user()->user->name }} <span class="caret"></span>
                            </a>

                            <ul class="dropdown-menu" role="menu">
                                <li><a href="{{ url('admin/password/reset') }}">修改密码</a></li>
                                <li>
                                    <a href="{{ url('/logout') }}"
                                       onclick="event.preventDefault();
                                                 document.getElementById('logout-form').submit();">
                                        退出登录
                                    </a>

                                    <form id="logout-form" action="{{ url('/logout') }}" method="POST" style="display: none;">
                                        {{ csrf_field() }}
                                    </form>
                                </li>
                            </ul>
                        </li>
                    @endif
                </ul>
            </div>
        </div>
    </nav>

    <div class="container">
        <div class="row">

            @if (count($errors) > 0)
                <div class="alert alert-danger">
                    <ul>
                        @foreach ($errors->all() as $error)
                            <li>{{ $error }}</li>
                        @endforeach
                    </ul>
                </div>
            @endif

            @if (session('successes'))
                <div class="alert alert-success">
                    <ul>
                        @foreach (session('successes') as $success)
                            <li>{{ $success }}</li>
                        @endforeach
                    </ul>
                </div>
            @endif

            @yield('content')

            </div>
        </div>
</div>
    <!-- Scripts -->
<script src="http://cdn.bootcss.com/vue/2.0.3/vue.min.js"></script>
<script src="http://cdn.bootcss.com/vue-resource/1.0.3/vue-resource.min.js"></script>
<script src="http://cdn.bootcss.com/jquery/3.1.1/jquery.min.js"></script>
<script src="http://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script>
    Vue.http.interceptors.push(function(request, next){
        request.headers.set('X-CSRF-TOKEN', Laravel.csrfToken);
        next();
    });
</script>
@yield('js')
</body>
</html>
